<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>小说</title>
    <link rel="stylesheet" href="css/mui.css">
    <link rel="stylesheet" href="css/novelDetail.css">
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/mui/3.7.1/js/mui.min.js"></script>
    <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
    <style type="text/css">
        .mui-table-view:before {
            height: 0;
        }
    </style>
</head>

<body>
    <div id="novelDeatil">
        <header class="mui-bar mui-bar-nav">
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">{{title}}</h1>
        </header>
        <div class="mui-content">
            <!--头部-->
            <div class="detail-head">
                <ul class="mui-table-view">
                    <li class="mui-table-view-cell mui-media novelDetail-head">
                        <a href="javascript:;" v-if="data.aladdin">
                            <img class="mui-pull-left cover" :src="data.aladdin.cover">
                            <div class="mui-media-body">
                                {{title}}
                                <p class="mui-ellipsis-1 author">{{data.aladdin.author}}</p>
                                <div class="category fontSmall colorGray">{{data.aladdin.category}}</div>
                                <div class="fontSmall">{{data.aladdin.tags}}</div>
                                <div class="fontSmall">字数：{{data.aladdin.words}}</div>
                            </div>
                        </a>
                    </li>
                </ul>
            </div>
            <!-- 目录 -->
            <ul class="mui-table-view" v-show="catalog">
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right">
                        这个接口没有目录，后期补上
                    </a>
                </li>
            </ul>
            <!--推荐-->
            <div style="width: 100%;overflow-x: auto;">
                <ul class="mui-table-view hya-flex" style="width: 1000px;">
                    <li class="mui-table-view-cell" v-for="item in recommend">
                        <a @click="change(item.title)">
                            <img :src="item.cover" style="width: 80px;" />
                        </a>
                    </li>

                </ul>
            </div>


        </div>
    </div>
</body>
<script type="text/javascript">
    mui.init();
    var novelDeatil_data = new Vue({
        el: "#novelDeatil",
        data: function () {
            return {
                title: localStorage.getItem('novelDeatil'),
                data: {},
                catalog: false,
                //相关推荐 
                recommend: []
            }
        },
        created: function () {
            this.$nextTick(function () {
                var that = this;
                that.getData();
            })
        },
        methods: {
            getData() {
                var that = this;
                //https://www.apiopen.top/novelInfoApi?name=
                $.get('https://www.apiopen.top/novelInfoApi?name=' + that.title).then(res => {
                    console.log(res);
                    if (res.code == 200) {
						mui.toast(res.msg)
                        that.data = res.data;
                        that.recommend = res.data.data;
                        that.catalog = true;
                    } else {
                        mui.toast(res.msg)
                    }
                })
            },
            change(title) {
                localStorage.getItem('novelDeatil', 'title');
                this.title = title;
                this.getData();
            }
        },
    })
</script>

</html>
